<template>
  <el-tabs class="stock" v-model="activeName">
    <el-tab-pane label="未分配数据" name="second">
    </el-tab-pane>
    <el-tab-pane label="已分配数据" name="first">
    </el-tab-pane>
    <div class="select-group">
      <div class="items" v-show="activeName === 'first'">
        <span class="items-text">批次名称</span>
        <el-select v-model="temp.folder" clearable filterable placeholder="请选择">
          <el-option
            v-for="item in folderList"
            :key="item.folderId"
            :label="item.folderName"
            :value="item.folderName">
          </el-option>
        </el-select>
      </div>
      <div class="items" v-show="activeName === 'first'">
        <span class="items-text">所属公司</span>
        <el-select v-model="temp.companyId" clearable filterable placeholder="请选择">
          <el-option
            v-for="item in companyArr"
            :key="item.companyId"
            :label="item.companyName"
            :value="item.companyId">
          </el-option>
        </el-select>
      </div>
      <div class="items" v-show="activeName !== 'first'">
        <span class="items-text">所属文件</span>
        <el-select v-model="temp.fileId" clearable filterable placeholder="请选择">
          <el-option
            v-for="item in fileList"
            :key="item.fileId"
            :label="item.fileName"
            :value="item.fileId">
          </el-option>
        </el-select>
      </div>
    </div>
    <div class="select-group" v-show="activeName !== 'first'">
      <div class="items">
        <span class="items-text">呼叫结果</span>
        <el-select v-model="temp.call" @change="selectChange" clearable filterable placeholder="请选择">
          <el-option
            v-for="item in callList"
            :key="item.callId"
            :label="item.callName"
            :value="item.callId">
          </el-option>
        </el-select>
      </div>
      <div class="items">
        <span class="items-text">转化结果</span>
        <el-select v-model="temp.vital" :disabled="temp.call !== 1" clearable filterable placeholder="请选择">
          <el-option
            v-for="item in vitalList"
            :key="item.vitalId"
            :label="item.vitalName"
            :value="item.vitalId">
          </el-option>
        </el-select>
      </div>
    </div>
    <div class="select-group">
      <div class="items">
        <span class="items-text">行业</span>
        <el-select v-model="temp.industryId" clearable filterable placeholder="请选择">
          <el-option
            v-for="item in industry"
            :key="item.industryId"
            :label="item.industryName"
            :value="item.industryId">
          </el-option>
        </el-select>
      </div>
      <div class="items" v-show="activeName !== 'first'">
        <span class="items-text">关键词</span>
        <el-select v-model="temp.keyword"
        clearable
        filterable
        remote
        :remote-method="key_remoteMethod"
        :loading="keyLoading"
        placeholder="请选择">
          <el-option
            v-for="(item,idx) in keyword"
            :key="idx"
            :label="item"
            :value="item">
          </el-option>
        </el-select>
      </div>
    </div>
    <div class="select-group" >
      <div class="items" v-show="activeName === 'first'" style="width: 600px;display: inline-block;">
        <span class="items-text">导入时间</span>
        <el-date-picker
          v-model="temp.timeValue"
          type="datetimerange"
          value-format='yyyy-MM-dd HH:mm:ss'
          :picker-options="timeOption"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          align="left">
        </el-date-picker>
      </div>
      <el-button v-waves
                 :disabled="activeName === 'first' ? listLoading : inListLoading"
                 size="medium"
                 type="success"
                 class="el-icon-search"
                 @click="getFolderList"
                 v-show="activeName === 'first'"
                 style="margin-left: 25px;"
      >
        <span style="padding-left:5px;">查询</span>
      </el-button>
    </div>
    <div class="select-group">
      <div class="items" v-show="activeName !== 'first'">
        <span class="items-text">系统标签</span>
        <el-select
        v-model="temp.sysLabel"
        clearable
        reserve-keyword
        filterable
        remote
        :remote-method="sys_remoteMethod"
        :loading="sysLoading"
        placeholder="请选择">
          <el-option
            v-for="(item,idx) in systemlabel"
            :key="idx"
            :label="item"
            :value="item">
          </el-option>
        </el-select>
      </div>
      <div class="items" v-show="activeName !== 'first'">
        <span class="items-text">号码归属地</span>
        <el-cascader
          filterable
          clearable
          change-on-select
          :options="areaList"
          v-model="temp.areaOptions">
        </el-cascader>
      </div>
      <el-button v-waves
                 :disabled="activeName === 'first' ? listLoading : inListLoading"
                 size="medium"
                 type="success"
                 class="el-icon-search"
                 @click="getAllotList"
                 v-show="activeName !== 'first'"
      >
        <span style="padding-left:5px;">查询</span>
      </el-button>
    </div>
    <h4>
      数据列表
      <div style="display:inline-block" v-show="activeName!=='first'">
        <el-button v-waves
                   @click="batchEvent(false)" class="eventBtn"
                   type="primary"
                   size="small"
                   icon="el-icon-edit-outline">
          选中分配
        </el-button>
        <el-button v-waves
                   @click="batchEvent(true)" class="eventBtn"
                   type="primary"
                   size="small"
                   icon="el-icon-edit-outline">
          批量分配
        </el-button>
      </div>
    </h4>

    <!-- 给table 加 key 是告诉vue 不要复用table元素 -->
    <el-table v-if="activeName === 'first'"
              empty-text="暂无任何批次信息"
              :data="list"
              key="firstTable"
              v-loading.body="listLoading"
              border
              fit
              style="width: 100%">
      <el-table-column align="center" label="数据批次">
        <template slot-scope="scope">
          <router-link v-if="scope.row.status == 2" style="color:#409eff" :to="{path:'/allocation/detail',query:{id:scope.row.folder}}">
            <span>{{!!scope.row.folder ? scope.row.folder : '-'}}</span>
          </router-link>
          <span v-else>{{!!scope.row.folder ? scope.row.folder : '-'}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="数量">
        <template slot-scope="scope">
          <span>{{ !!scope.row.count ? scope.row.count : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="所属公司">
        <template slot-scope="scope">
          <span>{{ !!scope.row.companyName ? scope.row.companyName : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="行业">
        <template slot-scope="scope">
          <span>{{!!scope.row.industryName ? scope.row.industryName : '-'}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="分发人">
        <template slot-scope="scope">
          <span>{{ !!scope.row.applicantName ? scope.row.applicantName : '-'}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核进度">
        <template slot-scope="scope">
          <el-tag :type="statusClassMap[scope.row.status * 1 - 1 ]">
            {{ statusTextMap[ scope.row.status * 1 - 1  ] }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核人">
        <template slot-scope="scope">
          <span>{{ !!scope.row.auditorName ? scope.row.auditorName : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="分发时间" width="100">
        <template slot-scope="scope">
          <span>{{scope.row.time.split('.')[0]}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="200">
        <template slot-scope="scope">
          <!--removeFolder(scope.row.folder,scope.row.companyId)-->
          <!--premitMethod(scope.row.folder,2)-->
          <el-button @click="premitMethod(scope.row.folder,1)" v-if="scope.row.status == 3" v-waves size="small" type="warning">重新提交</el-button>
          <el-button @click="openEvent(scope.row,true)" v-if="scope.row.status == 2" v-waves size="small" type="danger">移除</el-button>
          <el-button @click="openEvent(scope.row,false)" v-if="scope.row.status == 1 || scope.row.status == 3" v-waves size="small" type="default">取消</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-table @selection-change="handleSelectionChange"
                key="secondTable"
                v-else
                empty-text="暂无任何数据信息"
                :data="inList"
                v-loading.body="inListLoading"
                border
                fit
                tooltip-effect="dark"
                >
        <el-table-column
          align="center"
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column align="center" label="客户ID">
          <template slot-scope="scope">
              <span>{{scope.row.customerName}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="所属文件">
          <template slot-scope="scope">
            <span>{{ !!scope.row.fileName ? scope.row.fileName : '-' }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="行业">
          <template slot-scope="scope">
            <span>{{scope.row.industryName}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="关键词">
          <template slot-scope="scope">
            <span>{{ !!scope.row.keyword ? scope.row.keyword : '-'}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="系统标签">
          <template slot-scope="scope">
            <span>{{ !!scope.row.sysLabel ? scope.row.sysLabel : '-' }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="呼叫/转化">
          <template slot-scope="scope">
            <span>{{ !!scope.row.callVital ? callVitalText[scope.row.callVital - 1] : '-' }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="号码归属地">
          <template slot-scope="scope">
            <span>{{ scope.row.provinceName + ( scope.row.cityName === '' ? '' :  '/' + scope.row.cityName ) }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="当前虚拟号">
          <template slot-scope="scope">
            <span>{{scope.row.virtualNumber}}</span>
          </template>
        </el-table-column>
      </el-table>

    <div v-show="!inListLoading && activeName !== 'first'" class="pagination-container">
        <el-pagination background
                       @size-change="handleSizeChange"
                       prev-text="上一页"
                       next-text="下一页"
                       @current-change="handleCurrentChange"
                       :current-page="inListQuery.current"
                       :page-sizes="[10,20,30,50]"
                       :page-size="inListQuery.pagesize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="inTotal">
        </el-pagination>
      </div>
    <div v-show="!listLoading && activeName === 'first'" class="pagination-container">
        <el-pagination background
                       @size-change="handleSizeChange"
                       prev-text="上一页"
                       next-text="下一页"
                       @current-change="handleCurrentChange"
                       :current-page="listQuery.current"
                       :page-sizes="[10,20,30,50]"
                       :page-size="listQuery.pagesize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="total">
        </el-pagination>
      </div>

    <el-dialog width="400px"
               title="分配"
               :visible.sync="infoFormVisible"
               @close="cancledialog('sendForm')"
    >
      <el-form :model="allot" :rules="rules" ref="sendForm">
        <!--这里必须套一个div 不然先点击批量后点击选中  弹框关闭时会报错-->
        <div>
          <el-form-item label="当前已选择 : "
                        v-show="!isBatch"
                        :label-width="formLabelWidth">
            <span>{{ multipleSelection.length }} 条</span>
          </el-form-item>
        </div>
        <div>
          <el-form-item prop="batchCount"
                        v-if="isBatch"
                        label="批量分配条数"
                        :label-width="formLabelWidth">
            <el-input style="width: 200px;" v-model.number.sync="allot.batchCount" type="number" placeholder="请输入条数"></el-input>
          </el-form-item>
        </div>
        <div>
          <el-form-item prop="folder"
                        label="批次名称"
                        :label-width="formLabelWidth">
            <el-input style="width: 200px;" v-model.sync="allot.folder"  placeholder="请输入批次名称"></el-input>
          </el-form-item>
        </div>
        <el-form-item v-if="activeName !== 'first'" label="所属公司" prop="allotSeleted" :label-width="formLabelWidth">
          <el-select v-model="allot.allotSeleted" clearable filterable placeholder="请选择">
            <el-option
              v-for="item in companyArr"
              :key="item.companyId"
              :label="item.companyName"
              :value="item.companyId">
            </el-option>
          </el-select>
        </el-form-item>
        <div>
          <el-form-item label="当前总条数 : "
                        :label-width="formLabelWidth">
            <span>{{ totalTemp }} 条</span>
          </el-form-item>
        </div>
        <div v-if="activeName === 'second'" class="batchMark">
          {{ '注释:' + ( !isBatch ?
                                '使用于少量目标数据分配。将列表中勾选的数据分配给所选择的目标公司。'
                                :
                                '适用于大批量数据移除。输入想要移除的数据数量。(一次最多分配'+ maxBatchNum +'条)')
          }}
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="mini" @click="() => isBatch ? batchSendEvent() : sendEvent()">分配</el-button>
        <el-button @click="infoFormVisible = false" size="mini">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :visible.sync="dialogVisible"
      width="30%"
      @click="dialogVisible = false"
    >
      <el-alert
        :title="'您确认要'+ (currentFolderItem.status == 2 ? '移除':'取消' ) + '该批次文件?'"
        type="warning"
        show-icon
        :closable="false"
      >
      </el-alert>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="enableEvent">确 定</el-button>
      </span>
    </el-dialog>
  </el-tabs>
</template>
<script>
import { mapGetters } from "vuex";
import waves from "@/directive/waves"; // 水波纹指令
import { getIndustryList } from "@/api/user"; //获取行业信息
import {
  getCompany,
  getKeyword,
  getSyslabel,
  getAreaList
} from "@/api/dataStock";
import {
  getFileList,
  getAllotList,
  setAllot,
  batchAllot,
  getFolder,
  getFolderList,
  premit,
  removeFolder
} from "@/api/allocation";
export default {
  name: "allocation",
  directives: {
    waves
  },
  data() {
    const timeOptions = {
      shortcuts: [
        {
          text: "最近一周",
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit("pick", [start, end]);
          }
        },
        {
          text: "最近一个月",
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit("pick", [start, end]);
          }
        },
        {
          text: "最近三个月",
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit("pick", [start, end]);
          }
        }
      ]
    };

    const CheckBatchNum = (rule, value, callback) => {
      let tempValue = value * 1;
      let maxNum =
        this.totalTemp > this.maxBatchNum ? this.maxBatchNum : this.totalTemp;
      if (!value) {
        callback(new Error("请输入要分配的条数"));
      } else if (!Number.isInteger(tempValue) || tempValue < 1) {
        this.allot.batchCount = "";
        callback(new Error("输入必须是大于0的数字"));
      } else if (tempValue > maxNum) {
        this.allot.batchCount = "";
        callback(
          new Error(
            maxNum >= this.maxBatchNum
              ? "单次处理不能大于" + maxNum + "条数"
              : "输入值不能大于" + maxNum + "条数"
          )
        );
      } else {
        callback();
      }
    };
    return {
      sysLoading: false,
      keyLoading: false,
      currentFolderItem: {},
      currentFlag: true,
      dialogVisible: false,
      callVitalText: ["未接听", "已接听,未留", "已接听,已留", "未拨打"],
      callList: [
        { callId: 1, callName: "已接听" },
        { callId: 2, callName: "未接听" }
      ],
      vitalList: [
        { vitalId: 1, vitalName: "已留" },
        { vitalId: 2, vitalName: "未留" }
      ],
      statusClassMap: ["warning", "success", "danger"],
      statusTextMap: ["待审核", "已分发", "审核未通过"],
      temp: {}, //筛选列结果集,
      searchTemp: {}, //查询所用条件结果
      totalTemp: null,
      timeOption: timeOptions,
      maxBatchNum: 2000,
      isBatch: true,
      folderList: [],
      areaList: [],
      companyArr: [],
      fileList: [],
      industry: [],
      keyword: [],
      systemlabel: [],
      allot: {
        allotSeleted: "", //所要分配的公司id
        batchCount: null,
        folder: ""
      },
      activeName: "second",
      multipleSelection: [], //列选中的列id
      infoFormVisible: false,
      formLabelWidth: "120px",
      rules: {
        allotSeleted: [
          { required: true, message: "请选择要分配的公司", trigger: "blur" }
        ],
        batchCount: [{ validator: CheckBatchNum, trigger: "blur" }],
        folder: [{ required: true, message: "请填写批次名称", trigger: "blur" }]
      },
      searchQueryFirst: null, //已分配查询条件结果集
      searchQuerySecond: null, //未分配查询条件结果集
      listQuery: {
        current: 1,
        pagesize: 10
      },
      list: [],
      total: null,
      listLoading: false,
      inListQuery: {
        current: 1,
        pagesize: 10
      },
      inList: [],
      inTotal: null,
      inListLoading: false
    };
  },
  created() {
    this.getOptions(); //加载基础选项值
    this.getFolderList(); //获取文件批次列表
    this.getAllotList();
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.$data.activeName = "second";
      // 通过 `vm` 访问组件实例
      getCompany()
        .then(res => {
          vm.$data.companyArr = res.data.info;
        })
        .catch(res => {
          vm.$message.error(res);
        });
      getFileList()
        .then(res => {
          let temp = res.data.info;
          vm.$data.fileList = temp;
        })
        .catch(res => {
          vm.$message.error(res);
        });

      vm.getFolderList(); //进入该路由都刷新该table
    });
  },
  computed: {
    ...mapGetters(["userInfo"])
  },
  watch: {
    activeName(val) {
      this.multipleSelection = []; //重置复选
      this.temp = {}; //重置筛选结果
    }
  },
  methods: {
    selectChange(val) {
      if (val !== 1) {
        delete this.temp.vital;
      }
    },
    openEvent(item, flag) {
      this.currentFolderItem = item;
      this.currentFlag = flag;
      this.dialogVisible = true;
    },
    enableEvent() {
      if (this.currentFlag) {
        this.removeFolder(
          this.currentFolderItem.folder,
          this.currentFolderItem.companyId
        );
      } else {
        this.premitMethod(this.currentFolderItem.folder, 2);
      }
      this.dialogVisible = false;
    },
    getFolderList() {
      this.listLoading = true;
      let temp = Object.assign({}, this.temp, this.listQuery);
      getFolderList(this.transData(temp))
        .then(res => {
          this.list = res.data.info;
          this.total = res.data.total;
          this.listLoading = false;
        })
        .catch(res => {
          this.$message.error(res);
          this.listLoading = false;
        });
    },
    premitMethod(folderName, stus) {
      //        stus   1:重新提交 2:取消
      let temp = { status: stus, folder: folderName };
      premit(temp)
        .then(res => {
          this.$message.success(res.msg);
          this.getFolderList();
        })
        .catch(res => {
          this.$message.error(res);
        });
    },
    removeFolder(folderName, companyId) {
      let temp = { folder: folderName, companyId: companyId };
      removeFolder(temp)
        .then(res => {
          this.$message.success(res.msg);
          this.getFolderList();
        })
        .catch(res => {
          this.$message.error(res);
        });
    },
    getAllotList() {
      this.inListLoading = true;
      let temp = Object.assign({}, this.temp, this.inListQuery, { status: 2 });
      temp = this.transData(temp);
      getAllotList(temp)
        .then(res => {
          this.inList = res.data.info;
          this.inTotal = res.data.total * 1;
          this.inListLoading = false;
          //成功后 把查询条件 赋值给  searchTemp
          this.searchTemp = Object.assign({}, this.temp);
          //把当前总条数给  totalTemp
          this.totalTemp = res.data.total * 1;
        })
        .catch(res => {
          this.$message.error(res);
          this.inListLoading = false;
        });
    },
    transData(tempObj) {
      for (var k in tempObj) {
        if (k === "areaOptions") {
          //提取地区的值
          if (tempObj[k].length) {
            tempObj["provinceId"] = tempObj[k][0];
            if (tempObj[k].length > 1) {
              tempObj["cityId"] = tempObj[k][1];
            }
            delete tempObj[k];
          } else {
            delete tempObj[k];
          }
        } else if (k === "timeValue") {
          if (tempObj[k] && tempObj[k].length) {
            tempObj["startTime"] = tempObj[k][0];
            tempObj["endTime"] = tempObj[k][1];
          }
          delete tempObj[k];
        } else {
          //删除空值
          tempObj[k] === "" ? delete tempObj[k] : null;
        }
      }
      return tempObj;
    },
    getOptions() {
      getFolder()
        .then(res => {
          this.folderList = res.data.info;
        })
        .catch(res => {
          this.$message.error(res);
        });
      getIndustryList()
        .then(res => {
          let temp = res.data.info;
          this.industry = temp;
        })
        .catch(res => {
          this.$message.error(res);
        });
      getCompany()
        .then(res => {
          this.companyArr = res.data.info;
        })
        .catch(res => {
          this.$message.error(res);
        });
      getAreaList()
        .then(res => {
          let temp = res.data.area;
          this.areaList = temp;
        })
        .catch(res => {
          this.$message.error(res);
        });
      getFileList()
        .then(res => {
          let temp = res.data.info;
          this.fileList = temp;
        })
        .catch(res => {
          this.$message.error(res);
        });
    },
    sys_remoteMethod(query) {
      if (query !== "") {
        this.sysLoading = true;
        getSyslabel(query)
          .then(res => {
            this.sysLoading = false;
            let temp = res.data.sysLabel;
            this.systemlabel = temp;
          })
          .catch(res => {
            this.sysLoading = false;
            this.$message.error(res);
          });
      }
    },
    key_remoteMethod(query) {
      if (query !== "") {
        this.keyLoading = true;
        getKeyword(query)
          .then(res => {
            this.keyLoading = false;
            let temp = res.data.keyword;
            this.keyword = temp;
          })
          .catch(res => {
            this.keyLoading = false;
            this.$message.error(res);
          });
      }
    },
    handleSizeChange(val) {
      this.activeName === "first"
        ? (this.listQuery.pagesize = val)
        : (this.inListQuery.pagesize = val);
      this.activeName === "first" ? this.getFolderList() : this.getAllotList();
    },
    handleCurrentChange(val) {
      this.activeName === "first"
        ? (this.listQuery.current = val)
        : (this.inListQuery.current = val);
      this.activeName === "first" ? this.getFolderList() : this.getAllotList();
    },
    sendEvent() {
      //单个数据操作
      this.$refs.sendForm.validate(valid => {
        if (!valid) {
          return;
        }
        if (!this.multipleSelection.length && !this.isBatch) {
          //如果未选中一条
          this.infoFormVisible = false;
          this.$message.error("您未有选中的操作项");
          return;
        }
        let tempData = { customerId: this.multipleSelection };
        tempData["companyId"] = this.allot.allotSeleted;
        tempData["folder"] = this.allot.folder;
        tempData["applicantId"] = this.userInfo.userId;
        setAllot(tempData)
          .then(res => {
            //完成后 再次请求两个列表
            this.getFolderList();
            this.getAllotList();
            this.$message.success(res.msg);
            this.infoFormVisible = false;
          })
          .catch(res => {
            this.$message.error(res);
            this.infoFormVisible = false;
          });
      });
    },
    batchSendEvent() {
      //批量操作
      this.$refs.sendForm.validate(valid => {
        if (!valid) {
          return;
        }
        let fullLoading = this.$loading({
          lock: true,
          text: "Loading",
          spinner: "el-icon-loading",
          background: "rgba(0, 0, 0, 0.7)"
        });
        //是否点击的批量
        let stus = 2; // 1 : 批量删除  2 : 批量分配;
        let tempData = {
          count: this.allot.batchCount,
          status: stus,
          companyId: this.allot.allotSeleted,
          folder: this.allot.folder,
          applicantId: this.userInfo.userId
        };
        tempData = Object.assign({}, tempData, this.searchTemp);
        batchAllot(tempData)
          .then(res => {
            fullLoading.close(); //关闭遮罩
            this.getFolderList();
            this.getAllotList();
            this.$message.success(res.msg);
            this.infoFormVisible = false;
          })
          .catch(res => {
            fullLoading.close(); //关闭遮罩
            this.$message.error(res);
            this.infoFormVisible = false;
          });
      });
    },
    cancledialog(userForm) {
      //重置表单
      this.$refs[userForm].resetFields();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val.map(v => v.customerId);
    },
    batchEvent(bool) {
      //控制是否是批量操作
      this.infoFormVisible = true;
      this.isBatch = bool;
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.stock {
  .el-alert--warning {
    background-color: #fff;
  }
  .eventBtn {
    margin-left: 15px;
  }
  .dialog-Item {
    margin-bottom: 15px;
    margin-left: 15px;
    .textItem {
      display: inline-block;
      width: 40%;
    }
  }
  .info-item {
    margin: 15px 0px 15px 50px;
    > div {
      display: inline-block;
      min-width: 250px;
    }
    .tipText {
      display: inline-block;
      margin-right: 10px;
      min-width: 100px;
      text-align: right;
    }
  }

  .batchMark {
    text-indent: 35px;
    font-size: 12px;
    color: #888;
    margin: 0 15px;
  }
}
</style>
